package com.hbnu.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;


@Component
@Aspect//此注解表明当前类为切面类

public class LoRecord {
    @Pointcut("execution(* com.hbnu.service.CartService.*(..))")
    public  void pointcut(){

    }
    @Before("pointcut()")
    public void beforeAddCart(){
        System.out.println("前置通知：在被增强方法（目标方法）之前执行....");
    }


    @Around("pointcut()")
    public void aroundAddCart(ProceedingJoinPoint proceedingJoinPoint)throws Throwable{
        System.out.println("环绕通知：在被增强方法（目标方法）之前执行...");

        proceedingJoinPoint.proceed();

        System.out.println("环绕通知：在被增强方法（目标方法）之后执行...");
    }
}























